﻿using System;
using System.Text;
using Zinnia.Common.Core;
using Zinnia.Common.Core.Imp;

namespace Zinnia.Common.Untilty
{
    /// <summary>
    /// 文件帮助类
    /// </summary>
    public sealed class FileHelper
    {
        private IFileService fileService = null;
        private FileHelper()
        {
            fileService = new FileService();
        }
        public static FileHelper Instance => new FileHelper();
        /// <summary>
        /// 写入文本
        /// </summary>
        /// <param name="content">写入内容</param>
        public void Write(string content, string relativePath, Encoding encode = null)
        {
            fileService.Write(content, relativePath, encode);
        }

        /// <summary>
        /// 读取文本信息
        /// </summary>
        /// <returns></returns>
        public string ReadFileText(string relativePath, Encoding encode = null)
        {
            return fileService.ReadFileText(relativePath, encode);
        }
    }
}
